package demo.demo5;

import java.lang.reflect.Proxy;

public class ProxyFactory {
    //声明目标对象
     private TrainStation station=new TrainStation();


    //获取代理对象的方法
    public SellTickets getProxyObject(){
        //返回代理对象
        SellTickets proyObject=(SellTickets) Proxy.newProxyInstance(station.getClass().getClassLoader(),station.getClass().getInterfaces(),
                new TrainStationInvocationHandler(station));
        return proyObject;
    }
}
